<%@ page contentType="text/html;charset=UTF-8" %>﻿
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>test jsp&ajax&spring mvc</title>
</head>
<body>
<hr/>
test ajax,test result:<br/>
<hr/>
<span id=result></span>
<hr/>
<button onclick='testFindUser()'>测试查询用户</button>
<hr/>
<button onclick='testInsert()'>测试新增1</button>
<hr/>
<button onclick='testT()'>测试事务2</button>

<script>
var ctx = '${ctx}';
</script>
<script type="text/javascript" src="${ctx}/static/jquery/1.8.2/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="${ctx}/static/test.js"></script>
<script type="text/javascript" src="${ctx}/static/util/jsonUtil.js"></script>
<script>
var testInsert = function(){
	var requestData = {"name":"abc","crawlerWeight":333,"crawlerType":"aaa","isNewsSnapshot":1,"isMetaSearcherSnapshot":1,"snapPath":"/opt/123123","isDownLoadPlugin":1,"isValid":1,"createTime":null,"start":0,"singleCount":0}
	
	$.ajax({
		url: ctx+"/collector/testInsert",
		type: "GET",
		data: requestData,
		dataType: "json",
		success: function(jsondata, statusText, xhr) {	
			alert(formatJson2Str(jsondata));
		}
		, error: function(xhr, message, error) {
			alert(formatJson2Str(jsondata));
		}
	 });
	
}

var testFindUser = function(){
	
	$.ajax({
		url: ctx+"/collector/startTestUser",
		type: "GET",
		dataType: "json",
		success: function(jsondata, statusText, xhr) {	
			alert(formatJson2Str(jsondata));
		}
		, error: function(xhr, message, error) {
			alert(formatJson2Str(jsondata));
		}
	 });
	
}

var testT = function(){
	var requestData = {"name":"abc","crawlerWeight":333,"crawlerType":"aaa","isNewsSnapshot":1,"isMetaSearcherSnapshot":1,"snapPath":"/opt/123123","isDownLoadPlugin":1,"isValid":1,"createTime":null,"start":0,"singleCount":0}
	
	$.ajax({
		url: ctx+"/collector/testTransactional",
		type: "GET",
		data: requestData,
		dataType: "json",
		success: function(jsondata, statusText, xhr) {	
			alert(formatJson2Str(jsondata));
		}
		, error: function(xhr, message, error) {
			alert(formatJson2Str(message));
		}
	 });
	
}

startTest();


</script>
</body>
</html>